#include "stdio.h"
#include "inc/core/ebsources.h"
#include "stdlib.h"

void ebsources_plot_t_profile_esource(char* homedir,
                                      char* filetosave,
                                      esource source,
                                      floatdig z,
                                      timevar start,
                                      timevar stop,
                                      timevar dt)
{
    FILE* to;
    timevar t;
    floatdig e;
    char fullname[MAX_BUF_SIZE];
    sprintf(fullname, "%s/%s", homedir, filetosave);
    to = fopen(fullname, "w");
    for (t = start; t <= stop; t += dt)
    {
        source(t, z, &e);
        fprintf(to, "%e\t%e\n", t , e);
    }
    fclose(to);
}

void ebsources_plot_z_profile_esource(char* homedir, char* filetosave, esource source, timevar t0, floatdig zstart, floatdig zstop, floatdig dz)
{
    FILE* to;
    floatdig z;
    floatdig e;
    char fullname[MAX_BUF_SIZE];
    sprintf(fullname, "%s/%s", homedir, filetosave);
    to = fopen(fullname, "w");
    for (z = zstart; z <= zstop; z += dz)
    {
        source(t0, z, &e);
        fprintf(to, "%e\t%e\n", z , e);
    }
    fclose(to);
}
